import request from '@/utils/request'

// 运营工单搜索
export const getTaskList = (pageIndex, pageSize, taskCode, status) => {
  return request({
    method: 'GET',
    url: '/api/task-service/task/search',
    params: {
      pageIndex,
      pageSize,
      taskCode,
      status,
      isRepair: false
    }
  })
}

// 运维工单搜索
export const getTaskList1 = (pageIndex, pageSize, taskCode, status) => {
  return request({
    method: 'GET',
    url: '/api/task-service/task/search',
    params: {
      pageIndex,
      pageSize,
      taskCode,
      status,
      isRepair: true
    }
  })
}

// 工单状态列表
export const getTaskStatus = () => {
  return request({
    method: 'GET',
    url: '/api/task-service/task/allTaskStatus'
  })
}

// 获取补货预警值
export function getValue() {
  return request({
    method: 'GET',
    url: '/api/task-service/task/supplyAlertValue'
  })
}

// 设置自动补货工单阈值
export function getAutoValue(data) {
  return request({
    method: 'POST',
    url: '/api/task-service/task/autoSupplyConfig',
    data
  })
}

// 根据售货机获取运营人员列表
export function getUserList(innerCode) {
  return request({
    method: 'GET',
    url: `/api/user-service/user/operatorList/${innerCode}`
  })
}

// 获取售货机货道详情
export function getMachineDetail(innerCode) {
  return request({
    method: 'GET',
    url: `/api/vm-service/channel/channelList/${innerCode}`
  })
}

// 创建工单
export function setWorkList(data) {
  return request({
    method: 'POST',
    url: '/api/task-service/task/create',
    data
  })
}

// 取消工单
export function cancelWorkList(data) {
  return request({
    method: 'POST',
    url: ' /api/task-service/task/cancel',
    data
  })
}

// 获取工单详情列表
export function getTaskInfo(taskId) {
  return request({
    url: `/api/task-service/task/taskInfo/${taskId}`,
    method: 'GET'
  })
}

// 补货详情工单
export function getTaskDetails(taskId) {
  return request({
    url: `/api/task-service/taskDetails/${taskId}`
  })
}

// 取消工单
export function getTaskCancel(params) {
  return request({
    url: '/api/task-service/task/cancel/',
    params
  })
}

// 获取所有工单类型
export function getTaskAll() {
  return request({
    url: '/api/task-service/taskType/list'
  })
}

// 根据售货机获取维修人员列表
export function getOperatorList(innerCode) {
  return request({
    method: 'GET',
    url: `/api/user-service/user/operatorList/${innerCode}`
  })
}
